<?php
/**
 * 应用自定义视图模板类
 * 
 * @version $Id: UserView.php 289 2012-05-02 08:40:09Z linsir123 $
 */
class UserView
{
	/**
	 * 初始化
	 */
	static function init()
	{
		static $__init = false;
		if ($__init) {
			return ;
		}
		$__init = true;
		
		///
		$view = App::getView();
		$engine = & $view->engine;
		
		/// 函数
		$engine->registerPlugin('function', 'navMenu', array('UserView', 'snavMenu'));
		
		///
		AppView::addJs("jquery.form.js");
		AppView::addJs("jquery.validate.js");
		AppView::addJs("_e35go/plugin.js");
	}
	
	/**
	 * 菜单
	 */
	static function snavMenu($params = null)
	{
		$cur = isset($params['cur']) ? trim($params['cur']) : null;
		$menus = array(
			'home' 		=> array('管理首页', 'main/home'),
			'order' 	=> array('我的订单', 'order/list'),
			'exchange' 	=> array('提款明细', 'exchange/list'),
			'profile' 	=> array('账户设置', 'account/profile'),
			'password'	=> array('修改密码', 'account/password')
		);
		if (M::user()->type != "") 
			unset($menus['password']);
			
		///
		$dom = "";
		foreach ($menus as $k => $v) {
			list($text, $route) = $v;
			
			///
			$url = lpUrl::__('user/'.$route);
			$class = $cur==$k ? ' class="on"' : '';
			$dom .= "<li {$class}><a href='{$url}'>{$text}</a></li>";
		}
		return "<ul>".$dom."</ul>";
	}
}
